public virtual void ExplosionStart(Explosion explosion, List <IntVec3> cellsToAffect) { if (this.def.explosionHeatEnergyPerCell > 1.401298E-45f) { GenTemperature.PushHeat(explosion.Position, explosion.Map, this.def.explosionHeatEnergyPerCell * (float)cellsToAffect.Count); } MoteMaker.MakeStaticMote(explosion.Position, explosion.Map, ThingDefOf.Mote_ExplosionFlash, explosion.radius * 6f); if (explosion.Map == Find.CurrentMap) { float magnitude = (explosion.Position.ToVector3Shifted() - Find.Camera.transform.position).magnitude; Find.CameraDriver.shaker.DoShake(4f * explosion.radius / magnitude); } this.ExplosionVisualEffectCenter(explosion); }
internal string DebugString() { string result; if (this.roomGroup.UsesOutdoorTemperature) { result = "uses outdoor temperature"; } else { if (Time.frameCount > RoomGroupTempTracker.debugGetFrame + 120) { RoomGroupTempTracker.debugWallEq = 0f; for (int i = 0; i < 40; i++) { RoomGroupTempTracker.debugWallEq += this.WallEqualizationTempChangePerInterval(); } RoomGroupTempTracker.debugWallEq /= 40f; RoomGroupTempTracker.debugGetFrame = Time.frameCount; } result = string.Concat(new object[] { " thick roof coverage: ", this.thickRoofCoverage.ToStringPercent("F0"), "\n thin roof coverage: ", this.ThinRoofCoverage.ToStringPercent("F0"), "\n no roof coverage: ", this.noRoofCoverage.ToStringPercent("F0"), "\n\n wall equalization: ", RoomGroupTempTracker.debugWallEq.ToStringTemperatureOffset("F3"), "\n thin roof equalization: ", this.ThinRoofEqualizationTempChangePerInterval().ToStringTemperatureOffset("F3"), "\n no roof equalization: ", this.NoRoofEqualizationTempChangePerInterval().ToStringTemperatureOffset("F3"), "\n deep equalization: ", this.DeepEqualizationTempChangePerInterval().ToStringTemperatureOffset("F3"), "\n\n temp diff from outdoors, adjusted: ", this.TempDiffFromOutdoorsAdjusted().ToStringTemperatureOffset("F3"), "\n tempChange e=20 targ= 200C: ", GenTemperature.ControlTemperatureTempChange(this.roomGroup.Cells.First <IntVec3>(), this.roomGroup.Map, 20f, 200f), "\n tempChange e=20 targ=-200C: ", GenTemperature.ControlTemperatureTempChange(this.roomGroup.Cells.First <IntVec3>(), this.roomGroup.Map, 20f, -200f), "\n equalize interval ticks: ", 120, "\n equalize cells count:", this.equalizeCells.Count }); } return(result); }
public static float GetTemperatureAtTile(int tile) { Map map = Current.Game.FindMap(tile); float result; if (map != null) { result = map.mapTemperature.OutdoorTemp; } else { result = GenTemperature.GetTemperatureFromSeasonAtTile(GenTicks.TicksAbs, tile); } return(result); }
public void DebugLogTemps() { StringBuilder stringBuilder = new StringBuilder(); float num = (Find.CurrentMap != null) ? Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile).y : 0f; stringBuilder.AppendLine("Latitude " + num); stringBuilder.AppendLine("-----Temperature for each hour this day------"); stringBuilder.AppendLine("Hour Temp SunEffect"); int num2 = Find.TickManager.TicksAbs - Find.TickManager.TicksAbs % 60000; for (int i = 0; i < 24; i++) { int absTick = num2 + i * 2500; stringBuilder.Append(i.ToString().PadRight(5)); stringBuilder.Append(Find.World.tileTemperatures.OutdoorTemperatureAt(map.Tile, absTick).ToString("F2").PadRight(8)); stringBuilder.Append(GenTemperature.OffsetFromSunCycle(absTick, map.Tile).ToString("F2")); stringBuilder.AppendLine(); } stringBuilder.AppendLine(); stringBuilder.AppendLine("-----Temperature for each twelfth this year------"); for (int j = 0; j < 12; j++) { Twelfth twelfth = (Twelfth)j; float num3 = Find.World.tileTemperatures.AverageTemperatureForTwelfth(map.Tile, twelfth); stringBuilder.AppendLine(twelfth.GetQuadrum() + "/" + SeasonUtility.GetReportedSeason(twelfth.GetMiddleYearPct(), num) + " - " + twelfth.ToString() + " " + num3.ToString("F2")); } stringBuilder.AppendLine(); stringBuilder.AppendLine("-----Temperature for each day this year------"); stringBuilder.AppendLine("Tile avg: " + map.TileInfo.temperature + "°C"); stringBuilder.AppendLine("Seasonal shift: " + GenTemperature.SeasonalShiftAmplitudeAt(map.Tile)); stringBuilder.AppendLine("Equatorial distance: " + Find.WorldGrid.DistanceFromEquatorNormalized(map.Tile)); stringBuilder.AppendLine(); stringBuilder.AppendLine("Day Lo Hi OffsetFromSeason RandomDailyVariation"); for (int k = 0; k < 60; k++) { int absTick2 = (int)((float)(k * 60000) + 15000f); int absTick3 = (int)((float)(k * 60000) + 45000f); stringBuilder.Append(k.ToString().PadRight(8)); stringBuilder.Append(Find.World.tileTemperatures.OutdoorTemperatureAt(map.Tile, absTick2).ToString("F2").PadRight(11)); stringBuilder.Append(Find.World.tileTemperatures.OutdoorTemperatureAt(map.Tile, absTick3).ToString("F2").PadRight(11)); stringBuilder.Append(GenTemperature.OffsetFromSeasonCycle(absTick3, map.Tile).ToString("F2").PadRight(11)); stringBuilder.Append(Find.World.tileTemperatures.OffsetFromDailyRandomVariation(map.Tile, absTick3).ToString("F2")); stringBuilder.AppendLine(); } Log.Message(stringBuilder.ToString()); }
private float WallEqualizationTempChangePerInterval() { if (equalizeCells.Count == 0) { return(0f); } float num = 0f; int num2 = Mathf.CeilToInt((float)equalizeCells.Count * 0.2f); for (int i = 0; i < num2; i++) { cycleIndex++; int index = cycleIndex % equalizeCells.Count; num = ((!GenTemperature.TryGetDirectAirTemperatureForCell(equalizeCells[index], Map, out float temperature)) ? (num + (Mathf.Lerp(Temperature, Map.mapTemperature.OutdoorTemp, 0.5f) - Temperature)) : (num + (temperature - Temperature))); } return(num / (float)num2 * (float)equalizeCells.Count * 120f * 0.00017f / (float)roomGroup.CellCount); }
public static List <Twelfth> TwelfthsInAverageTemperatureRange(int tile, float minTemp, float maxTemp) { List <Twelfth> twelfths = new List <Twelfth>(); for (int i = 0; i < 12; i++) { float num = GenTemperature.AverageTemperatureAtTileForTwelfth(tile, (Twelfth)i); if (num >= minTemp && num <= maxTemp) { twelfths.Add((Twelfth)i); } } List <Twelfth> twelfths2; if (twelfths.Count <= 1 || twelfths.Count == 12) { twelfths2 = twelfths; } else { if (twelfths.Contains(Twelfth.Twelfth) && twelfths.Contains(Twelfth.First)) { Twelfth twelfth = twelfths.First((Twelfth m) => !twelfths.Contains((Twelfth)(m - Twelfth.Second))); List <Twelfth> list = new List <Twelfth>(); for (int j = (int)twelfth; j < 12; j++) { if (!twelfths.Contains((Twelfth)j)) { break; } list.Add((Twelfth)j); } for (int k = 0; k < 12; k++) { if (!twelfths.Contains((Twelfth)k)) { break; } list.Add((Twelfth)k); } } twelfths2 = twelfths; } return(twelfths2); }
private float WallEqualizationTempChangePerInterval() { if (this.equalizeCells.Count == 0) { return(0f); } float num = 0f; int num2 = Mathf.CeilToInt((float)((float)this.equalizeCells.Count * 0.20000000298023224)); for (int i = 0; i < num2; i++) { this.cycleIndex++; int index = this.cycleIndex % this.equalizeCells.Count; float num3 = default(float); num = ((!GenTemperature.TryGetDirectAirTemperatureForCell(this.equalizeCells[index], this.Map, out num3)) ? (num + (Mathf.Lerp(this.Temperature, this.Map.mapTemperature.OutdoorTemp, 0.5f) - this.Temperature)) : (num + (num3 - this.Temperature))); } float num4 = num / (float)num2; float num5 = num4 * (float)this.equalizeCells.Count; return((float)(num5 * 120.0 * 0.00016999999934341758 / (float)this.roomGroup.CellCount)); }
public static bool TryGetAirTemperatureAroundThing(Thing t, out float temperature) { float num = 0f; int num2 = 0; List <IntVec3> list = GenAdjFast.AdjacentCells8Way(t); for (int i = 0; i < list.Count; i++) { float num3 = default(float); if (list[i].InBounds(t.Map) && GenTemperature.TryGetDirectAirTemperatureForCell(list[i], t.Map, out num3)) { num += num3; num2++; } } if (num2 > 0) { temperature = num / (float)num2; return(true); } temperature = 21f; return(false); }
public static float GetTemperature(this IntVec3 loc, Map map) { return(GenTemperature.GetTemperatureForCell(loc, map)); }
internal string DebugString() { if (roomGroup.UsesOutdoorTemperature) { return("uses outdoor temperature"); } if (Time.frameCount > debugGetFrame + 120) { debugWallEq = 0f; for (int i = 0; i < 40; i++) { debugWallEq += WallEqualizationTempChangePerInterval(); } debugWallEq /= 40f; debugGetFrame = Time.frameCount; } return(" thick roof coverage: " + thickRoofCoverage.ToStringPercent("F0") + "\n thin roof coverage: " + ThinRoofCoverage.ToStringPercent("F0") + "\n no roof coverage: " + noRoofCoverage.ToStringPercent("F0") + "\n\n wall equalization: " + debugWallEq.ToStringTemperatureOffset("F3") + "\n thin roof equalization: " + ThinRoofEqualizationTempChangePerInterval().ToStringTemperatureOffset("F3") + "\n no roof equalization: " + NoRoofEqualizationTempChangePerInterval().ToStringTemperatureOffset("F3") + "\n deep equalization: " + DeepEqualizationTempChangePerInterval().ToStringTemperatureOffset("F3") + "\n\n temp diff from outdoors, adjusted: " + TempDiffFromOutdoorsAdjusted().ToStringTemperatureOffset("F3") + "\n tempChange e=20 targ= 200C: " + GenTemperature.ControlTemperatureTempChange(roomGroup.Cells.First(), roomGroup.Map, 20f, 200f) + "\n tempChange e=20 targ=-200C: " + GenTemperature.ControlTemperatureTempChange(roomGroup.Cells.First(), roomGroup.Map, 20f, -200f) + "\n equalize interval ticks: " + 120 + "\n equalize cells count:" + equalizeCells.Count); }
public static string GetAverageTemperatureLabel(int tile) { return(Find.WorldGrid[tile].temperature.ToStringTemperature("F1") + " " + string.Format("({0} {1} {2})", GenTemperature.MinTemperatureAtTile(tile).ToStringTemperature("F0"), "RangeTo".Translate(), GenTemperature.MaxTemperatureAtTile(tile).ToStringTemperature("F0"))); }
public static Danger NormalMaxDanger(this Pawn p) { if (p.CurJob != null && p.CurJob.playerForced) { return(Danger.Deadly); } if (FloatMenuMakerMap.makingFor == p) { return(Danger.Deadly); } if (p.Faction == Faction.OfPlayer) { if (p.health.hediffSet.HasTemperatureInjury(TemperatureInjuryStage.Minor) && GenTemperature.FactionOwnsPassableRoomInTemperatureRange(p.Faction, p.SafeTemperatureRange(), p.MapHeld)) { return(Danger.None); } return(Danger.Some); } return(Danger.Some); }
public static string ToStringTemperatureOffset(this float celsiusTemp, string format = "F1") { celsiusTemp = GenTemperature.CelsiusToOffset(celsiusTemp, Prefs.TemperatureMode); return(celsiusTemp.ToStringTemperatureRaw(format)); }