public Danger DangerFor(Pawn p) { if (Current.ProgramState == ProgramState.Playing) { if (this.cachedDangersForFrame != Time.frameCount) { this.cachedDangers.Clear(); this.cachedDangersForFrame = Time.frameCount; } else { for (int i = 0; i < this.cachedDangers.Count; i++) { if (this.cachedDangers[i].Key == p) { return(this.cachedDangers[i].Value); } } } } Room room = this.Room; float temperature = room.Temperature; FloatRange floatRange = p.SafeTemperatureRange(); Danger danger = (Danger)(floatRange.Includes(temperature) ? 1 : ((!floatRange.ExpandedBy(80f).Includes(temperature)) ? 3 : 2)); if (Current.ProgramState == ProgramState.Playing) { this.cachedDangers.Add(new KeyValuePair <Pawn, Danger>(p, danger)); } return(danger); }
public static bool FactionOwnsPassableRoomInTemperatureRange(Faction faction, FloatRange tempRange, Map map) { if (faction == Faction.OfPlayer) { List <Room> allRooms = map.regionGrid.allRooms; for (int i = 0; i < allRooms.Count; i++) { Room room = allRooms[i]; if (room.RegionType.Passable() && !room.Fogged && tempRange.Includes(room.Temperature)) { return(true); } } return(false); } return(false); }