public void setFrozenTerrain() { if (!Settings.showCold) { return; } if (this.temperature < 0 && this.temperature < this.weather.freezeAt && this.weather.freezeTerrain != null) { if (this.isFlooded && this.weather.freezeTerrain != currentTerrain) { if (currentTerrain.HasModExtension <TerrainWeatherReactions>()) { TerrainWeatherReactions curWeather = currentTerrain.GetModExtension <TerrainWeatherReactions>(); this.changeTerrain(curWeather.freezeTerrain); } } else if (!this.isFrozen) { this.changeTerrain(weather.freezeTerrain); if (baseTerrain.defName == "TKKN_Lava") { this.map.GetComponent <Watcher>().lavaCellsList.Remove(location); } } this.isFrozen = true; this.isThawed = false; } else if (temperature > 0) { if (!this.isThawed) { if (this.baseTerrain.defName == "TKKN_Lava") { this.map.GetComponent <Watcher>().lavaCellsList.Add(location); } this.isFrozen = false; this.isThawed = true; this.changeTerrain(baseTerrain); } } }
public void setFloodedTerrain() { if (!Settings.showRain) { return; } TerrainDef floodTerrain = weather.floodTerrain; if (isFrozen) { TerrainWeatherReactions currWeather = currentTerrain.GetModExtension <TerrainWeatherReactions>(); TerrainDef frozenTerrain = currWeather.freezeTerrain; if (frozenTerrain != null) { changeTerrain(frozenTerrain); } } else if (overrideType == "dry") { this.howWetPlants = 100; floodTerrain = baseTerrain; changeTerrain(floodTerrain); } else if (floodTerrain != null && currentTerrain != floodTerrain) { changeTerrain(floodTerrain); this.isFlooded = true; if (!floodTerrain.HasTag("Water")) { this.isFlooded = false; this.howWetPlants = 100; this.leaveLoot(); } else { this.clearLoot(); } } }
public void doCellEnvironment(IntVec3 c) { if (!this.cellWeatherAffects.ContainsKey(c)) { return; } cellData cell = this.cellWeatherAffects[c]; cell.DoCellSteadyEffects(); if (this.ticks % 2 == 0) { cell.unpack(); } TerrainDef currentTerrain = c.GetTerrain(this.map); Room room = c.GetRoom(this.map, RegionType.Set_All); bool roofed = this.map.roofGrid.Roofed(c); bool flag2 = room != null && room.UsesOutdoorTemperature; bool gettingWet = false; cell.gettingWet = false; //check if the terrain has been floored DesignationCategoryDef cats = currentTerrain.designationCategory; if (cats != null) { if (cats.defName == "Floors") { cell.baseTerrain = currentTerrain; } } //spawn special things if (Rand.Value < .0001f) { if (c.InBounds(this.map)) { string defName = ""; if (currentTerrain.defName == "TKKN_Lava") { defName = "TKKN_LavaRock"; } else if (currentTerrain.defName == "TKKN_LavaRock_RoughHewn" && this.map.Biome.defName == "TKKN_VolcanicFlow") { defName = "TKKN_SteamVent"; } if (defName != "") { Thing check = (Thing)(from t in c.GetThingList(this.map) where t.def.defName == defName select t).FirstOrDefault <Thing>(); if (check == null) { Thing thing = (Thing)ThingMaker.MakeThing(ThingDef.Named(defName), null); GenSpawn.Spawn(thing, c, map); } } } } #region Rain if (Settings.showRain && !cell.currentTerrain.HasTag("TKKN_Wet")) { //if it's raining in this cell: if (!roofed && this.map.weatherManager.curWeather.rainRate > .0001f) { if (this.floodThreat < 1090000) { this.floodThreat += 1 + 2 * (int)Math.Round(this.map.weatherManager.curWeather.rainRate); } gettingWet = true; cell.gettingWet = true; cell.setTerrain("wet"); } else if (Settings.showRain && !roofed && this.map.weatherManager.curWeather.snowRate > .001f) { gettingWet = true; cell.gettingWet = true; cell.setTerrain("wet"); } else { if (this.map.weatherManager.curWeather.rainRate == 0) { this.floodThreat--; } //DRY GROUND cell.setTerrain("dry"); } } #endregion #region Cold bool isCold = this.checkIfCold(c); if (isCold) { cell.setTerrain("frozen"); } else { cell.setTerrain("thaw"); } #region Frost if (isCold) { //handle frost based on snowing if (!roofed && this.map.weatherManager.SnowRate > 0.001f) { this.map.GetComponent <FrostGrid>().AddDepth(c, this.map.weatherManager.SnowRate * -.01f); } else { CreepFrostAt(c, 0.46f * .3f, map); } } else { float frosty = cell.temperature * -.025f; // float frosty = this.map.mapTemperature.OutdoorTemp * -.03f; this.map.GetComponent <FrostGrid>().AddDepth(c, frosty); if (this.map.GetComponent <FrostGrid>().GetDepth(c) > .3f) { // cell.isMelt = true; } } #endregion #region plant damage //HANDLE PLANT DAMAGES: if (gettingWet) { //note - removed ismelt because the dirt shouldn't dry out in winter, and snow wets the ground then. if (cell.howWetPlants < (float)100) { if (this.map.weatherManager.curWeather.rainRate > 0) { cell.howWetPlants += this.map.weatherManager.curWeather.rainRate * 2; } else if (this.map.weatherManager.curWeather.snowRate > 0) { cell.howWetPlants += this.map.weatherManager.curWeather.snowRate * 2; } } } else { if (this.map.mapTemperature.OutdoorTemp > 20) { cell.howWetPlants += -1 * ((this.map.mapTemperature.OutdoorTemp / humidity) / 10); if (cell.howWetPlants <= 0) { if (cell.currentTerrain.HasModExtension <TerrainWeatherReactions>()) { TerrainWeatherReactions weather = cell.currentTerrain.GetModExtension <TerrainWeatherReactions>(); if (weather.dryTerrain == null) { //only hurt plants on terrain that's not wet. this.hurtPlants(c, false, true); } } else { this.hurtPlants(c, false, true); } } } } #endregion /* MAKE THIS A WEATHER #region heat * Thing overlayHeat = (Thing)(from t in c.GetThingList(this.map) * where t.def.defName == "TKKN_HeatWaver" * select t).FirstOrDefault<Thing>(); * if (this.checkIfHot(c)) * { * if (overlayHeat == null && Settings.showHot) * { * Thing heat = ThingMaker.MakeThing(ThingDefOf.TKKN_HeatWaver, null); * GenSpawn.Spawn(heat, c, map); * } * } * else * { * if (overlayHeat != null) * { * overlayHeat.Destroy(); * } * } #endregion */ #region Puddles if (cell.howWet < 3 && Settings.showRain && (cell.isMelt || gettingWet)) { cell.howWet += 2; } else if (cell.howWet > -1) { cell.howWet--; } //PUDDLES Thing puddle = (Thing)(from t in c.GetThingList(this.map) where t.def.defName == "TKKN_FilthPuddle" select t).FirstOrDefault <Thing>(); if (cell.howWet == 3 && !isCold && this.MaxPuddles > this.totalPuddles && cell.currentTerrain.defName != "TKKN_SandBeachWetSalt") { if (puddle == null) { FilthMaker.MakeFilth(c, this.map, ThingDef.Named("TKKN_FilthPuddle"), 1); this.totalPuddles++; } } else if (cell.howWet <= 0 && puddle != null) { puddle.Destroy(); this.totalPuddles--; } cell.isMelt = false; #endregion /*CELL SHOULD BE HANDLING THIS NOW: * //since it changes, make sure the lava list is still good: * * if (currentTerrain.defName == "TKKN_Lava") { * this.lavaCellsList.Add(c); * } else { * this.lavaCellsList.Remove(c); * } */ this.cellWeatherAffects[c] = cell; }