public override string TransformStatusLabel(string label) { string recipeLabel = activeRecipe?.LabelCap ?? "QE_VatGrowerNoRecipe".Translate(); if (status == CrafterStatus.Filling || status == CrafterStatus.Finished) { return(label + " " + recipeLabel.CapitalizeFirst()); } if (status == CrafterStatus.Crafting) { float daysRemaining = GenDate.TicksToDays(TicksLeftToCraft); if (daysRemaining > 1.0) { return(recipeLabel.CapitalizeFirst() + " (" + String.Format("{0:0.0}", daysRemaining) + " " + "QE_VatGrowerDaysRemaining".Translate() + ")"); } else { return(" " + recipeLabel.CapitalizeFirst() + " (" + String.Format("{0:0.0}", (TicksLeftToCraft / 2500.0f)) + " " + "QE_VatGrowerHoursRemaining".Translate() + ")"); } } return(base.TransformStatusLabel(label)); }
public override string CompInspectStringExtra() { StringBuilder builder = new StringBuilder(); builder.Append($"{Translator.Translate("SiegeCampLevel")} {siegeCampLevel + 1}"); if (siegeCampLevel < maxLevel) { builder.Append($"{Translator.Translate("SiegeCampUpdateTimer")} {GenDate.TicksToDays(timer).ToString("f2")}"); } return(builder.ToString()); }
public override string CompInspectStringExtra() { string result; if (Bomb != null && Bomb.Disarmed) { result = $"{Translator.Translate("BombDisarmed")}"; } else { result = $"{Translator.Translate("DetonationIn")}{GenDate.TicksToDays(detonationTimer).ToString("f2")}"; } return(result); }
private float GetBaseEstimatedLifespan(Thing thing, BuildableDef def, ThingDef stuffDef, bool withWearFactor = true) { if (!((ThingDef)def).useHitPoints) { return(float.PositiveInfinity); } // For def if (thing == null) { return(GenDate.TicksToDays(Mathf.RoundToInt(BaseWearInterval * def.GetStatValueAbstract(RimWorld.StatDefOf.MaxHitPoints, stuffDef) / (withWearFactor ? WearFactor(null, def, stuffDef) : 1f)))); } // For thing return(GenDate.TicksToDays(Mathf.RoundToInt(BaseWearInterval * thing.MaxHitPoints / (withWearFactor ? WearFactor(thing, def, stuffDef) : 1f)))); }
public override string CompInspectStringExtra() { StringBuilder builder = new StringBuilder(); builder.Append($"{Translator.Translate("PlanetWillBeDestroyed")}{GenDate.TicksToDays(Timer).ToString("f2")}"); builder.Append($"\n{"PlayerSilverCount".Translate(PlayerSilver)}"); builder.Append($"\n{"FactionGift".Translate(FactionSilver)}"); builder.Append($"HelpingFactionsList".Translate()); if (helpFactionList.Length > 0) { builder.Append(helpFactionList); } return(builder.ToString()); }
private float GetBaseEstimatedLifespan(SurvivalTool tool, BuildableDef def) { SurvivalToolProperties props = def.GetModExtension <SurvivalToolProperties>() ?? SurvivalToolProperties.defaultValues; if (!((ThingDef)def).useHitPoints) { return(float.PositiveInfinity); } // For def if (tool == null) { return(GenDate.TicksToDays(Mathf.RoundToInt((BaseWearInterval * def.GetStatValueAbstract(StatDefOf.MaxHitPoints)) / props.toolWearFactor))); } // For thing StuffPropsTool stuffProps = tool.Stuff?.GetModExtension <StuffPropsTool>() ?? StuffPropsTool.defaultValues; float wearFactor = tool.def.GetModExtension <SurvivalToolProperties>().toolWearFactor *(stuffProps.wearFactorMultiplier); return(GenDate.TicksToDays(Mathf.RoundToInt((BaseWearInterval * tool.MaxHitPoints) / wearFactor))); }
public void DoWindowContents(Rect wrect) { var options = new Listing_Standard(); options.ColumnWidth = (wrect.width - Listing.ColumnSpacing) / 2; options.Begin(wrect); TextAnchor anchor = Text.Anchor; options.Label("TD.SettingIslandDays".Translate() + String.Format("{0:0.0}", islandAddedDays)); islandAddedDays = options.Slider(islandAddedDays, 0f, 20f); options.Label("TD.SettingRemotenessSpeed".Translate()); distanceFactor = options.Slider(distanceFactor, .05f, .5f); options.Label("TD.SettingRemotenessFactor".Translate() + String.Format("{0:0.0}x", visitDiminishingFactor)); visitDiminishingFactor = options.Slider(visitDiminishingFactor, 0.1f, 5); int totalDays = 10; Rect graphLine = options.GetRect(Text.LineHeight * 12); Rect graphRect = graphLine.LeftPartPixels(graphLine.height); TDWidgets.DrawGraph(graphRect, "TD.DaysTravel".Translate(), "TD.DaysAdded".Translate(), "{0:0}", "{0:0}", 0, totalDays, DelayDays.AddedDays, null, null, 5); Map map = Find.CurrentMap; if (map != null && (Prefs.DevMode || Harmony.DEBUG)) //That's one roundabout way to check DEBUG { int gameTicks = GenTicks.TicksGame; options.Label("TD.GameTicks".Translate() + gameTicks); FieldInfo lastThreatBigTickInfo = AccessTools.Field(typeof(StoryState), "lastThreatBigTick"); int lastThreatTick = (int)lastThreatBigTickInfo.GetValue(map.storyState); options.Label("TD.ForMap".Translate() + map.info.parent.LabelShortCap); options.Label("TD.BigThreatsDelayed".Translate() + lastThreatTick); float days = GenDate.TicksToDays(lastThreatTick - gameTicks); if (days >= 0) { options.Label("TD.XDaysInFuture".Translate()); } if (options.ButtonText("TD.ResetToNOW".Translate())) { lastThreatBigTickInfo.SetValue(map.StoryState, GenTicks.TicksGame); } options.Label(String.Format("TD.ThreatWillDelay".Translate(), DelayDays.DelayRaidDays(map))); options.Label(String.Format("TD.GuestWillDelay".Translate(), DelayDays.DelayAllyDays(map))); } options.NewColumn(); options.CheckboxLabeled("TD.WriteLogs".Translate(), ref logResults); options.Label(String.Format("TD.SettingMinimumWealth".Translate(), wealthLimit)); wealthLimit = options.Slider(wealthLimit, 1, 1000000); options.Label(String.Format("TD.SettingMaximumWealth".Translate(), wealthMax)); wealthMax = options.Slider(wealthMax, 1, 1000000); options.Label(String.Format("TD.SettingWealthFactor".Translate(), wealthFactor)); wealthFactor = options.Slider(wealthFactor, 0f, 1f); options.Label("TD.SettingCurvinessFactor".Translate()); wealthCurvy = options.Slider(wealthCurvy, 0f, 50f); graphLine = options.GetRect(Text.LineHeight * 16); graphRect = graphLine.LeftPartPixels(graphLine.height); TDWidgets.DrawGraph(graphRect, "TD.ColonyWealth".Translate(), "TD.PercentDelayReduced".Translate(), "{0:0}", "{0:P0}", 0, 1000000, DelayDays.WealthReduction, 0, 1f); Text.Anchor = anchor; options.End(); }
public override string CompInspectStringExtra() { return($"{Translator.Translate("ShipPartTimeout")} {(int)GenDate.TicksToDays(lifeTime)}"); }
//TODO: optimize function internal static FoodSourceRating FoodScoreFor(Policy policy, Pawn eater, Pawn getter, Thing food, bool noDistanceFactor = false, bool quickScore = false) { var obj = new FoodSourceRating(); obj.FoodSource = food; obj.DefRecord = food.GetFoodDefRecord(); // ------ Distance factor ------ bool inInventory = (getter.inventory != null && getter.inventory.innerContainer.Contains(food)); if (!noDistanceFactor) { float distanceFactor; if (inInventory) distanceFactor = 0f; else distanceFactor = -((food.Position - eater.Position).LengthManhattan) * policy.distanceFactor; obj.AddComp("Distance", distanceFactor); } if (inInventory && getter == eater && food.def.ingestible.preferability >= FoodPreferability.MealAwful) { obj.AddComp("Inventory", 500f); } // ------------- Policy food category factor ------------- //if (!policy.unrestricted) // obj.AddComp(food.DetermineFoodCategory().ToString(), policy.GetFoodScoreOffset(eater, food)); // ------------- Prey score factor ------------- const float PREY_FACTOR_MULTIPLIER = 5f; //Because the vanilla prey factor is fairly weak. { if (food is Pawn) { var preyScore = RimWorld.FoodUtility.GetPreyScoreFor(eater, food as Pawn) * PREY_FACTOR_MULTIPLIER; //ducktape, negates the distance factor of the vanilla function as it is already calculated by the mod. preyScore += (eater.Position - food.Position).LengthHorizontal * PREY_FACTOR_MULTIPLIER; obj.AddComp("Prey (ratio=" + FoodUtils.GetPreyRatio(eater, food as Pawn).ToString("F2") + ")", preyScore); return obj; } } // ------------- Food def optimality offset ------------- if (policy.optimalityOffsetMatters && food.def.ingestible != null) { obj.AddComp("Def", food.def.ingestible.optimalityOffset); } if (!quickScore) { // ------------- Mood effect factor ------------- //float num2 = 0f; if (eater.needs != null && eater.needs.mood != null && policy.moodEffectMatters) { List<ThoughtDef> list; if (!(food is RimWorld.Building_NutrientPasteDispenser)) list = RimWorld.FoodUtility.ThoughtsFromIngesting(eater, food); else list = ((RimWorld.Building_NutrientPasteDispenser)food).GetBestMealThoughtsFor(eater); for (int i = 0; i < list.Count; i++) { obj.AddComp(list[i].defName, policy.moodEffectFactor * Detours.Access.FoodOptimalityEffectFromMoodCurve.Evaluate(list[i].stages[0].baseMoodEffect)); } } // ------------- Cost factor (waste factor aswell) ------------- //TODO: concurrent based waste factor. float costRatio; float foodNutrition; var curFoodLevel = eater.needs.food.CurLevel; var maxFoodLevel = eater.needs.food.MaxLevel; if (food.def.IsFoodDispenser) foodNutrition = ThingDefOf.MealNutrientPaste.ingestible.nutrition; else if (food.def.IsCorpse) { var corpse = food as Corpse; BodyPartRecord part = corpse.GetBestBodyPartToEat(eater, curFoodLevel)); if (part != null) foodNutrition = RimWorld.FoodUtility.GetBodyPartNutrition(corpse.InnerPawn, part); } else foodNutrition = food.def.ingestible.nutrition; if (foodNutrition >= 0.1f) { //TODO: ajust; add record for the NPD if (food is RimWorld.Building_NutrientPasteDispenser) costRatio = (food.def.building.nutritionCostPerDispense * 0.05f) / ThingDefOf.MealNutrientPaste.ingestible.nutrition; else costRatio = (obj.DefRecord.costFactor); if (food.def.IsCorpse) costRatio *= 0.25f; //TODO: combine waste & cost factors float actualMealCost = costRatio * foodNutrition; float costFactorOffset = Math.Max(0, actualMealCost - (maxFoodLevel - curFoodLevel)) * -Config.CostFactor /* * policy.costFactorMultiplier*/; //float costFactorOffset = (actualMealCost - (maxFoodLevel - curFoodLevel)) * -Config.CostFactor /* * policy.costFactorMultiplier*/; //* Config.CostFactor * policy.costFactorMultiplier; if (costFactorOffset != 0f) obj.AddComp("Hunger/Cost (min=" + actualMealCost.ToString("F2") + ")", costFactorOffset); } // ------------- TODO: Rot factor ------------- var compRottable = food.TryGetComp<CompRottable>(); if (compRottable != null) { var ticksUntilRotAtCurrentTemp = compRottable.TicksUntilRotAtCurrentTemp; const int V = 30000; if (ticksUntilRotAtCurrentTemp < V) { obj.AddComp("Rotting soon", Config.RottingScoreFactor / (ticksUntilRotAtCurrentTemp - V)); } else { var daysToRotStart = GenDate.TicksToDays(ticksUntilRotAtCurrentTemp); if (daysToRotStart >= 40) { obj.AddComp("Rots in " + daysToRotStart.ToString("####") + " days.", -Mathf.Min(Config.UnrottableFoodScoreOffset * 0.7f, Mathf.Log((1 + daysToRotStart)) * 20)); } } } else { obj.AddComp("Never rots", -Config.UnrottableFoodScoreOffset); } } return obj; }
public override string GetInspectString() { return("HowToGivePawns".Translate(PawnsRequired, GenDate.TicksToDays(TicksToEnd).ToString("f2"))); }
private void DrawQuestCard(Rect rect, ref int y, Quest quest) { Rect r = new Rect(10, y, rect.width - 20, 90); Rect titleRect = new Rect(15, y, rect.width - 20, 90); string questLabel = quest.CardLabel.Length > 36 ? quest.CardLabel.Substring(0, 36) : quest.CardLabel; Widgets.Label(titleRect, questLabel); Text.Font = GameFont.Tiny; Rect rect2 = new Rect(15, y + 22, rect.width - 20, 20); Widgets.Label(rect2, quest.Faction != null ? "FactionComm".Translate(quest.Faction.Name) : "NoFactionComm".Translate()); rect2.y += 20; Widgets.Label(rect2, quest.UnlimitedTime ? "UnlimitedTime".Translate() : "QuestTimer".Translate(GenDate.TicksToDays(quest.TicksToPass).ToString("f2"))); rect2.y += 25; if (quest.Target != null) { GUI.color = JumpToLocationColor; Text.Anchor = TextAnchor.MiddleCenter; Widgets.DrawHighlightIfMouseover(rect2); Widgets.Label(rect2, "JumpToLocation".Translate(quest.Target.TryGetPrimaryTarget().ToString())); if (Widgets.ButtonInvisible(rect2)) { GlobalTargetInfo target = quest.Target.TryGetPrimaryTarget(); CameraJumper.TryJumpAndSelect(target); Close(); } GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; } Text.Font = GameFont.Small; if (currentQuest == quest) { Widgets.DrawHighlight(r); GUI.color = quest.Faction.Color; Widgets.DrawBox(r); GUI.color = Color.white; } else { Widgets.DrawHighlightIfMouseover(r); } GUI.color = CommCardBGColor; Widgets.DrawHighlight(r); GUI.color = Color.white; if (Widgets.ButtonInvisible(r)) { rewardCost = 0; currentQuest = quest; if (currentQuest.Rewards != null) { foreach (var k in currentQuest.Rewards) { rewardCost += k.def.BaseMarketValue * k.stackCount; } } } y += 107; }