public static int CostToMove(int caravanTicksPerMove, int start, int end, int?ticksAbs = null, bool perceivedStatic = false, StringBuilder explanation = null, string caravanTicksPerMoveExplanation = null) { int result; if (start == end) { result = 0; } else { if (explanation != null) { explanation.Append(caravanTicksPerMoveExplanation); explanation.AppendLine(); } StringBuilder stringBuilder = (explanation == null) ? null : new StringBuilder(); float num; if (perceivedStatic && explanation == null) { num = Find.WorldPathGrid.PerceivedMovementDifficultyAt(end); } else { num = WorldPathGrid.CalculatedMovementDifficultyAt(end, perceivedStatic, ticksAbs, stringBuilder); } float roadMovementDifficultyMultiplier = Find.WorldGrid.GetRoadMovementDifficultyMultiplier(start, end, stringBuilder); if (explanation != null) { explanation.AppendLine(); explanation.Append("TileMovementDifficulty".Translate() + ":"); explanation.AppendLine(); explanation.Append(stringBuilder.ToString().Indented(" ")); explanation.AppendLine(); explanation.Append(" = " + (num * roadMovementDifficultyMultiplier).ToString("0.#")); } int num2 = (int)((float)caravanTicksPerMove * num * roadMovementDifficultyMultiplier); num2 = Mathf.Clamp(num2, 1, 120000); if (explanation != null) { explanation.AppendLine(); explanation.AppendLine(); explanation.Append("FinalCaravanMovementSpeed".Translate() + ":"); int num3 = Mathf.CeilToInt((float)num2 / 1f); explanation.AppendLine(); explanation.Append(string.Concat(new string[] { " ", (60000f / (float)caravanTicksPerMove).ToString("0.#"), " / ", (num * roadMovementDifficultyMultiplier).ToString("0.#"), " = ", (60000f / (float)num3).ToString("0.#"), " ", "TilesPerDay".Translate() })); } result = num2; } return(result); }
private string GetTileTip(int tile, int pathIndex) { int num = paths[pathIndex].NodesReversed.IndexOf(tile); int num2 = ((num > 0) ? paths[pathIndex].NodesReversed[num - 1] : ((pathIndex >= paths.Count - 1 || paths[pathIndex + 1].NodesReversed.Count < 2) ? (-1) : paths[pathIndex + 1].NodesReversed[paths[pathIndex + 1].NodesReversed.Count - 2])); int num3 = cachedTicksToWaypoint[pathIndex] + CaravanArrivalTimeEstimator.EstimatedTicksToArrive(paths[pathIndex].FirstNode, tile, paths[pathIndex], 0f, CaravanTicksPerMove, GenTicks.TicksAbs + cachedTicksToWaypoint[pathIndex]); int num4 = GenTicks.TicksAbs + num3; StringBuilder stringBuilder = new StringBuilder(); if (num3 != 0) { stringBuilder.AppendLine("EstimatedTimeToTile".Translate(num3.ToStringTicksToDays("0.##"))); } stringBuilder.AppendLine("ForagedFoodAmount".Translate() + ": " + Find.WorldGrid[tile].biome.forageability.ToStringPercent()); stringBuilder.Append(VirtualPlantsUtility.GetVirtualPlantsStatusExplanationAt(tile, num4)); if (num2 != -1) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); StringBuilder stringBuilder2 = new StringBuilder(); float num5 = WorldPathGrid.CalculatedMovementDifficultyAt(num2, perceivedStatic: false, num4, stringBuilder2); float roadMovementDifficultyMultiplier = Find.WorldGrid.GetRoadMovementDifficultyMultiplier(tile, num2, stringBuilder2); stringBuilder.Append("TileMovementDifficulty".Translate() + ":\n" + stringBuilder2.ToString().Indented(" ")); stringBuilder.AppendLine(); stringBuilder.Append(" = "); stringBuilder.Append((num5 * roadMovementDifficultyMultiplier).ToString("0.#")); } return(stringBuilder.ToString()); }
public void RecalculatePerceivedMovementDifficultyAt(int tile, int?ticksAbs = null) { if (Find.WorldGrid.InBounds(tile)) { bool flag = this.PassableFast(tile); this.movementDifficulty[tile] = WorldPathGrid.CalculatedMovementDifficultyAt(tile, true, ticksAbs, null); if (flag != this.PassableFast(tile)) { Find.WorldReachability.ClearCache(); } } }
protected override void FillTab() { Rect outRect = new Rect(0f, 0f, WITab_Terrain.WinSize.x, WITab_Terrain.WinSize.y).ContractedBy(10f); Rect rect = new Rect(0f, 0f, outRect.width - 16f, Mathf.Max(this.lastDrawnHeight, outRect.height)); Widgets.BeginScrollView(outRect, ref this.scrollPosition, rect, true); Rect rect2 = rect; Rect rect3 = rect2; Text.Font = GameFont.Medium; Widgets.Label(rect3, base.SelTile.biome.LabelCap); Rect rect4 = rect2; rect4.yMin += 35f; rect4.height = 99999f; Text.Font = GameFont.Small; Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.verticalSpacing = 0f; listing_Standard.Begin(rect4); Tile selTile = base.SelTile; int selTileID = base.SelTileID; listing_Standard.Label(selTile.biome.description, -1f, null); listing_Standard.Gap(8f); listing_Standard.GapLine(12f); if (!selTile.biome.implemented) { listing_Standard.Label(selTile.biome.LabelCap + " " + "BiomeNotImplemented".Translate(), -1f, null); } listing_Standard.LabelDouble("Terrain".Translate(), selTile.hilliness.GetLabelCap(), null); if (selTile.Roads != null) { listing_Standard.LabelDouble("Road".Translate(), (from roadlink in selTile.Roads select roadlink.road.label).Distinct <string>().ToCommaList(true).CapitalizeFirst(), null); } if (selTile.Rivers != null) { listing_Standard.LabelDouble("River".Translate(), selTile.Rivers.MaxBy((Tile.RiverLink riverlink) => riverlink.river.degradeThreshold).river.LabelCap, null); } if (!Find.World.Impassable(selTileID)) { StringBuilder stringBuilder = new StringBuilder(); int tile = selTileID; bool perceivedStatic = false; StringBuilder explanation = stringBuilder; string rightLabel = (WorldPathGrid.CalculatedMovementDifficultyAt(tile, perceivedStatic, null, explanation) * Find.WorldGrid.GetRoadMovementDifficultyMultiplier(selTileID, -1, stringBuilder)).ToString("0.#"); if (WorldPathGrid.WillWinterEverAffectMovementDifficulty(selTileID) && WorldPathGrid.GetCurrentWinterMovementDifficultyOffset(selTileID, null, null) < 2f) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append(" ("); stringBuilder.Append("MovementDifficultyOffsetInWinter".Translate(new object[] { "+" + 2f.ToString("0.#") })); stringBuilder.Append(")"); } listing_Standard.LabelDouble("MovementDifficulty".Translate(), rightLabel, stringBuilder.ToString()); } if (selTile.biome.canBuildBase) { listing_Standard.LabelDouble("StoneTypesHere".Translate(), (from rt in Find.World.NaturalRockTypesIn(selTileID) select rt.label).ToCommaList(true).CapitalizeFirst(), null); } listing_Standard.LabelDouble("Elevation".Translate(), selTile.elevation.ToString("F0") + "m", null); listing_Standard.GapLine(12f); listing_Standard.LabelDouble("AvgTemp".Translate(), GenTemperature.GetAverageTemperatureLabel(selTileID), null); listing_Standard.LabelDouble("OutdoorGrowingPeriod".Translate(), Zone_Growing.GrowingQuadrumsDescription(selTileID), null); listing_Standard.LabelDouble("Rainfall".Translate(), selTile.rainfall.ToString("F0") + "mm", null); if (selTile.biome.foragedFood != null && selTile.biome.forageability > 0f) { listing_Standard.LabelDouble("Forageability".Translate(), selTile.biome.forageability.ToStringPercent() + " (" + selTile.biome.foragedFood.label + ")", null); } else { listing_Standard.LabelDouble("Forageability".Translate(), "0%", null); } listing_Standard.LabelDouble("AnimalsCanGrazeNow".Translate(), (!VirtualPlantsUtility.EnvironmentAllowsEatingVirtualPlantsNowAt(selTileID)) ? "No".Translate() : "Yes".Translate(), null); listing_Standard.GapLine(12f); listing_Standard.LabelDouble("AverageDiseaseFrequency".Translate(), string.Format("{0} {1}", (60f / selTile.biome.diseaseMtbDays).ToString("F1"), "PerYear".Translate()), null); listing_Standard.LabelDouble("TimeZone".Translate(), GenDate.TimeZoneAt(Find.WorldGrid.LongLatOf(selTileID).x).ToStringWithSign(), null); StringBuilder stringBuilder2 = new StringBuilder(); Rot4 rot = Find.World.CoastDirectionAt(selTileID); if (rot.IsValid) { stringBuilder2.AppendWithComma(("HasCoast" + rot.ToString()).Translate()); } if (Find.World.HasCaves(selTileID)) { stringBuilder2.AppendWithComma("HasCaves".Translate()); } if (stringBuilder2.Length > 0) { listing_Standard.LabelDouble("SpecialFeatures".Translate(), stringBuilder2.ToString().CapitalizeFirst(), null); } if (Prefs.DevMode) { listing_Standard.LabelDouble("Debug world tile ID", selTileID.ToString(), null); } this.lastDrawnHeight = rect4.y + listing_Standard.CurHeight; listing_Standard.End(); Widgets.EndScrollView(); }
public static int CostToMove(int caravanTicksPerMove, int start, int end, int?ticksAbs = null, bool perceivedStatic = false, StringBuilder explanation = null, string caravanTicksPerMoveExplanation = null) { if (start == end) { return(0); } if (explanation != null) { explanation.Append(caravanTicksPerMoveExplanation); explanation.AppendLine(); } StringBuilder stringBuilder = ((explanation != null) ? new StringBuilder() : null); float num = ((!perceivedStatic || explanation != null) ? WorldPathGrid.CalculatedMovementDifficultyAt(end, perceivedStatic, ticksAbs, stringBuilder) : Find.WorldPathGrid.PerceivedMovementDifficultyAt(end)); float roadMovementDifficultyMultiplier = Find.WorldGrid.GetRoadMovementDifficultyMultiplier(start, end, stringBuilder); if (explanation != null) { explanation.AppendLine(); explanation.Append("TileMovementDifficulty".Translate() + ":"); explanation.AppendLine(); explanation.Append(stringBuilder.ToString().Indented(" ")); explanation.AppendLine(); explanation.Append(" = " + (num * roadMovementDifficultyMultiplier).ToString("0.#")); } int value = (int)((float)caravanTicksPerMove * num * roadMovementDifficultyMultiplier); value = Mathf.Clamp(value, 1, 30000); if (explanation != null) { explanation.AppendLine(); explanation.AppendLine(); explanation.Append("FinalCaravanMovementSpeed".Translate() + ":"); int num2 = Mathf.CeilToInt((float)value / 1f); explanation.AppendLine(); explanation.Append(" " + (60000f / (float)caravanTicksPerMove).ToString("0.#") + " / " + (num * roadMovementDifficultyMultiplier).ToString("0.#") + " = " + (60000f / (float)num2).ToString("0.#") + " " + "TilesPerDay".Translate()); } return(value); }