public static string ShowBestRoad(Pawn p) { RoadDef BestRoadDef = null; if (PawnBuildingUtility.HealthyColonist(p)) { foreach (RoadDef thisDef in DefDatabase <RoadDef> .AllDefs) { if (thisDef.HasModExtension <DefModExtension_RotR_RoadDef>() && thisDef.GetModExtension <DefModExtension_RotR_RoadDef>().built) // Only add RoadDefs that are buildable, based on DefModExtension_RotR_RoadDef.built { DefModExtension_RotR_RoadDef RoadDefMod = thisDef.GetModExtension <DefModExtension_RotR_RoadDef>(); if (PawnBuildingUtility.ConstructionLevel(p) >= RoadDefMod.minConstruction) { if ((BestRoadDef == null) || (thisDef.movementCostMultiplier < BestRoadDef.movementCostMultiplier)) { BestRoadDef = thisDef; } } } } if (BestRoadDef != null) { return(BestRoadDef.label); } } return("-"); }
public static string ShowSkill(Pawn p) { if (PawnBuildingUtility.HealthyColonist(p)) { return(String.Format("{0:0}", PawnBuildingUtility.ConstructionLevel(p))); } return("-"); }
public static string ShowConstructionValue(Pawn p) { if (PawnBuildingUtility.HealthyColonist(p)) { return(String.Format("{0:0.##}", PawnBuildingUtility.ConstructionValue(p))); } if (PawnBuildingUtility.HealthyPackAnimal(p)) { return(String.Format("+{0:0.##}", PawnBuildingUtility.ConstructionValue(p))); } return("-"); }
private void DoRow(Rect rect, Pawn p) { GUI.BeginGroup(rect); Rect rect2 = rect.AtZero(); CaravanThingsTabUtility.DoAbandonButton(rect2, p, base.SelCaravan); rect2.width -= 24f; Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, p); rect2.width -= 24f; if (Mouse.IsOver(rect2)) { Widgets.DrawHighlight(rect2); } Rect rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f); Widgets.ThingIcon(rect3, p, 1f); Rect bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f); GenMapUI.DrawPawnLabel(p, bgRect, 1f, 100f, null, GameFont.Small, false, false); float num = bgRect.xMax; for (int i = 0; i < 3; i++) { Rect rect5 = new Rect(num, 0f, 100f, 50f); if (Mouse.IsOver(rect5)) { Widgets.DrawHighlight(rect5); } Text.Anchor = TextAnchor.MiddleCenter; string s = ""; switch (i) { case 0: s = PawnBuildingUtility.ShowConstructionValue(p); break; case 1: s = PawnBuildingUtility.ShowSkill(p); break; case 2: s = PawnBuildingUtility.ShowBestRoad(p); break; default: s = "-"; break; } Widgets.Label(rect5, s); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; TooltipHandler.TipRegion(rect5, s); num += 125f; } if (p.Downed) { GUI.color = new Color(1f, 0f, 0f, 0.5f); Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width); GUI.color = Color.white; } GUI.EndGroup(); }
/* * Amount of work : * - Construction speed (0.5 + 0.15 per level) times the construct success chance (0.75 to 1.13 - lvl 8 is 1) * - Pack animals help as well (see below) */ public float AmountOfWork(bool verbose = false) { var pawns = GetCaravan().PawnsListForReading; DefModExtension_RotR_RoadDef roadDefModExtension = null; try { roadDefModExtension = site.roadDef.GetModExtension <DefModExtension_RotR_RoadDef>(); } catch { /* Either there's no site, no roaddef, or no modextension. In any case, not much to do here */ } //site.roadDef.GetModExtension<DefModExtension_RotR_RoadDef>().minConstruction ; var totalConstruction = 0f; var totalConstructionAboveMinLevel = 0f; var animalConstruction = 0f; foreach (var pawn in pawns) { /* * if (pawn.IsFreeColonist && pawn.health.State == PawnHealthState.Mobile) * { * totalConstruction += pawn.GetStatValue(StatDefOf.ConstructionSpeed) * pawn.GetStatValue(StatDefOf.ConstructSuccessChance); * * if (roadDefModExtension!=null && pawn.skills.GetSkill(SkillDefOf.Construction).levelInt >= roadDefModExtension.minConstruction) * { * totalConstructionAboveMinLevel += pawn.GetStatValue(StatDefOf.ConstructionSpeed) * pawn.GetStatValue(StatDefOf.ConstructSuccessChance); * } * } * else if (pawn.RaceProps.packAnimal && pawn.health.State == PawnHealthState.Mobile) * { * animalConstruction += pawn.GetStatValue(StatDefOf.ConstructionSpeed) * pawn.GetStatValue(StatDefOf.ConstructSuccessChance); * } */ var PawnConstructionValue = PawnBuildingUtility.ConstructionValue(pawn); if (PawnBuildingUtility.HealthyColonist(pawn)) { totalConstruction += PawnConstructionValue; if (roadDefModExtension != null && PawnBuildingUtility.ConstructionLevel(pawn) >= roadDefModExtension.minConstruction) { totalConstructionAboveMinLevel += PawnConstructionValue; } continue; } if (PawnBuildingUtility.HealthyPackAnimal(pawn)) { animalConstruction += PawnConstructionValue; } } if (roadDefModExtension != null) { var ratioOfConstructionAboveMinLevel = totalConstructionAboveMinLevel / totalConstruction; if (ratioOfConstructionAboveMinLevel < roadDefModExtension.percentageOfminConstruction) { // Check minimum construction level requirements if needed var ratioActuallyWorked = ratioOfConstructionAboveMinLevel / roadDefModExtension.percentageOfminConstruction; totalConstruction *= ratioActuallyWorked; if (verbose) { Messages.Message( "RoadsOfTheRim_InsufficientConstructionMinLevel".Translate(totalConstruction, roadDefModExtension.percentageOfminConstruction.ToString("P0"), roadDefModExtension.minConstruction), MessageTypeDefOf.NegativeEvent); } } } // Pack animals can only add as much work as humans (i.e. : at best, pack animals double the amount of work) if (animalConstruction > totalConstruction) { animalConstruction = totalConstruction; } totalConstruction += animalConstruction; return(totalConstruction); }