// Extracted and modified from GenStep_ScatterShrines: private static bool IsMapRectClear(CellRect mapRect, Map map) { foreach (IntVec3 cell in mapRect) { if (cell.InBounds(map)) { TerrainDef terrainDef = map.terrainGrid.TerrainAt(cell); if (terrainDef.HasTag("River") || terrainDef.HasTag("Road")) { return(false); } if (!GenConstruct.CanBuildOnTerrain(ThingDefOf.Wall, cell, map, Rot4.North, null, null)) { return(false); } } List <Thing> thingList = cell.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].def.category == ThingCategory.Building || thingList[i].def.category == ThingCategory.Pawn || thingList[i].def.category == ThingCategory.Ethereal) { return(false); } } } return(true); }
public float thirstRate() { TerrainDef terrain = pawn.Position.GetTerrain(pawn.MapHeld); if (terrain != null && terrain.HasTag("TKKN_Water") && !terrain.HasTag("TKKN_Salt")) { return(-.2f); } float rate = .01f; if (pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.TKKN_Sweat) != null) { rate += .01f; } if (pawn.health.hediffSet.GetFirstHediffOfDef(RimWorld.HediffDefOf.Heatstroke) != null) { rate += .02f; } if (pawn.pather.MovingNow) { rate += .03f; } rate += pawn.AmbientTemperature / 1000; return(rate); }
public static void Postfix(IntVec3 c, Pawn pawn, bool __result) { if (__result == true || pawn.Map == null || !pawn.RaceProps.Animal) { return; } TerrainDef terrain = c.GetTerrain(pawn.Map); if (terrain != null && (terrain.HasTag("TKKN_Lava") || terrain.HasTag("TKKN_Swim"))) { __result = true; } }
protected bool CanPlaceAncientBuildingInRange(CellRect rect, Map map) { foreach (IntVec3 c in rect.Cells) { if (c.InBounds(map)) { TerrainDef terrainDef = map.terrainGrid.TerrainAt(c); if (terrainDef.HasTag("River") || terrainDef.HasTag("Road")) { return(false); } } } return(true); }
public static void Prefix(ref bool renderBody, ref float angle, PawnRenderer __instance) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (pawn == null || !pawn.Position.IsValid || pawn.Dead) { return; } Comp_GraphicRotator rotator = pawn.GetComp <Comp_GraphicRotator>(); if (rotator != null) { angle = rotator.getCurrentAngle(); } if (!pawn.RaceProps.Humanlike || pawn.MapHeld == null) { return; } TerrainDef terrain = pawn.Position.GetTerrain(pawn.MapHeld); if (terrain != null) { if (terrain.HasTag("TKKN_Swim")) { renderBody = false; } } }
private IntVec3 getSwimmingCell(Pawn pawn) { IntVec3 wanderRoot = this.GetWanderRoot(pawn); IntVec3 c = RCellFinder.RandomWanderDestFor(pawn, wanderRoot, this.wanderRadius, this.wanderDestValidator, PawnUtility.ResolveMaxDanger(pawn, this.maxDanger)); for (int i = 0; i < 20; i++) { IntVec3 c2 = c + GenAdj.AdjacentCellsAndInside[i]; if (!c2.InBounds(pawn.Map)) { return(IntVec3.Invalid); } if (!c2.Standable(pawn.Map)) { return(IntVec3.Invalid); } if (c2 is IntVec3 && c2.IsValid) { TerrainDef terrain = c2.GetTerrain(pawn.Map); if (terrain.HasTag("TKKN_Swim")) { return(c2); } } } return(IntVec3.Invalid); }
public void setFloodedTerrain() { if (!Settings.showRain) { return; } TerrainDef floodTerrain = weather.floodTerrain; if (overrideType == "dry") { floodTerrain = baseTerrain; changeTerrain(floodTerrain); } else if (floodTerrain != null && currentTerrain != floodTerrain) { changeTerrain(floodTerrain); this.isFlooded = true; if (!floodTerrain.HasTag("Water")) { this.isFlooded = false; this.leaveLoot(); } } }
public static void Prefix(ref bool renderBody, ref float angle, PawnRenderer __instance) { if (!Settings.allowPawnsSwim) { return; } Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (pawn == null || !pawn.Position.IsValid || pawn.Dead) { return; } if (!pawn.RaceProps.Humanlike || pawn.MapHeld == null) { return; } TerrainDef terrain = pawn.Position.GetTerrain(pawn.MapHeld); if (terrain != null) { if (terrain.HasTag("TKKN_Swim")) { renderBody = false; } } }
public static void AddDefaultFishableTags() { foreach (string tname in DefaultFishableWaters) { TerrainDef t = DefDatabase <TerrainDef> .GetNamed(tname, false); if (t != null && !t.HasTag("NonFishable") && !t.HasTag("Fishable")) { if (t.tags == null) { t.tags = new List <string>(); } t.tags.Add("Fishable"); } } }
// // Methods // protected override bool CanScatterAt(IntVec3 loc, Map map) { if (!base.CanScatterAt(loc, map)) { return(false); } Rot4 rot; if (!this.TryGetRandomValidRotation(loc, map, out rot)) { return(false); } if (this.terrainValidationRadius > 0f) { foreach (IntVec3 current in GenRadial.RadialCellsAround(loc, this.terrainValidationRadius, true)) { if (current.InBounds(map)) { TerrainDef terrain = current.GetTerrain(map); for (int i = 0; i < this.terrainValidationDisallowed.Count; i++) { if (terrain.HasTag(this.terrainValidationDisallowed[i])) { return(false); } } } } return(true); } return(true); }
public static bool Prefix(Pawn_PathFollower __instance) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (pawn.RaceProps.Animal) { TerrainDef terrain = pawn.Position.GetTerrain(pawn.Map); if (terrain.HasTag("TKKN_Swim") || terrain.HasTag("TKKN_Lava")) { if (!PatchStartPath.PawnCanOccupy(pawn.Position, pawn) && !PatchStartPath.TryRecoverFromUnwalkablePosition(true, pawn)) { return(false); } } } return(true); }
public static void DyingCheck(Pawn pawn, TerrainDef terrain) { //drowning == immobile and in water if (pawn == null || terrain == null) { return; } if (pawn.RaceProps.Humanlike && pawn.health.Downed && terrain.HasTag("TKKN_Wet")) { float damage = .0005f; //if they're awake, take less damage if (!pawn.health.capacities.CanBeAwake) { if (terrain.HasTag("TKKN_Swim")) { damage = .0001f; } else { return; } } //heavier clothing hurts them more List <Apparel> apparel = pawn.apparel.WornApparel; float weight = 0f; for (int i = 0; i < apparel.Count; i++) { weight += apparel[i].HitPoints / 10000; } damage += weight / 5000; HealthUtility.AdjustSeverity(pawn, HediffDef.Named("TKKN_Drowning"), damage); HediffDef hediffDef = HediffDefOf.TKKN_Drowning; if (pawn.Faction.IsPlayer && pawn.health.hediffSet.GetFirstHediffOfDef(hediffDef) == null && pawn.RaceProps.Humanlike) { string text = "TKKN_NPS_DrowningText".Translate(); Messages.Message(text, MessageTypeDefOf.NeutralEvent); } } else if (pawn.RaceProps.Humanlike && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.TKKN_Drowning) != null) { pawn.health.RemoveHediff(pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.TKKN_Drowning)); } }
public void spawnSpecialElements(IntVec3 c) { TerrainDef terrain = c.GetTerrain(map); foreach (ElementSpawnDef element in DefDatabase <ElementSpawnDef> .AllDefs) { bool canSpawn = true; foreach (string biome in element.forbiddenBiomes) { if (map.Biome.defName == biome) { canSpawn = false; break; } } foreach (string biome in element.allowedBiomes) { if (map.Biome.defName != biome) { canSpawn = false; break; } } if (!canSpawn) { continue; } // Log.Error(element.thingDef.defName + " " +map.Biome.defName); foreach (string allowed in element.terrainValidationAllowed) { if (terrain.defName == allowed) { canSpawn = true; break; } } foreach (string notAllowed in element.terrainValidationAllowed) { if (terrain.HasTag(notAllowed)) { canSpawn = false; break; } } if (canSpawn && Rand.Value < .0001f) { Thing thing = (Thing)ThingMaker.MakeThing(element.thingDef, null); GenSpawn.Spawn(thing, c, map); } } }
protected bool CanPlaceAncientBuildingInRange(CellRect rect, Map map) { foreach (IntVec3 cell in rect.Cells) { if (cell.InBounds(map)) { TerrainDef terrainDef = map.terrainGrid.TerrainAt(cell); if (terrainDef.HasTag("River") || terrainDef.HasTag("Road")) { return(false); } if (!GenConstruct.CanBuildOnTerrain(ThingDefOf.Wall, cell, map, Rot4.North)) { return(false); } } } return(true); }
private bool CanPlaceInRange(CellRect rect, Map map) { foreach (IntVec3 c in rect.Cells) { if (c.InBounds(map)) { TerrainDef terrainDef = map.terrainGrid.TerrainAt(c); if (terrainDef.HasTag("River") || terrainDef.HasTag("Road")) { return(false); } if (!GenConstruct.CanBuildOnTerrain(ThingDefOf.Wall, c, map, Rot4.North, null, null)) { return(false); } } } return(true); }
static void Postfix(ref bool __result, IntVec3 c, Map map) { if (__result && !DeepWaterValid) { TerrainDef terrain = map.terrainGrid.TerrainAt(c); if (terrain != null) { __result = !terrain.HasTag(SwimmingLoader.DeepWaterTag); } } }
public static bool UnreachableTerrainCheck(this Pawn pawn, TerrainDef terrain) { if (pawn != null && pawn.def.modExtensions != null) { foreach (DefModExtension ext in pawn.def.modExtensions) { TerrainMovementPawnRestrictions restrictions = pawn.LoadTerrainMovementPawnRestrictionsExtension(ext); if (restrictions != null) { if (restrictions.stayOffTerrainTag != null && terrain.HasTag(restrictions.stayOffTerrainTag)) { return(true); } if (restrictions.stayOnTerrainTag != null && !terrain.HasTag(restrictions.stayOnTerrainTag)) { return(true); } } } } return(false); }
public static bool UnreachableTerrainCheck(IEnumerable <DefModExtension> modExtensions, TerrainDef terrain) { if (modExtensions != null) { foreach (DefModExtension ext in modExtensions) { TerrainMovementPawnRestrictions restrictions = LoadTerrainMovementPawnRestrictionsExtension(ext); if (restrictions != null) { if (restrictions.stayOffTerrainTag != null && terrain.HasTag(restrictions.stayOffTerrainTag)) { return(true); } if (restrictions.stayOnTerrainTag != null && !terrain.HasTag(restrictions.stayOnTerrainTag)) { return(true); } } } } return(false); }
public override bool doBorder(IntVec3 c) { TerrainDef currentTerrain = c.GetTerrain(this.parent.Map); if (currentTerrain == this.Props.wetTile) { return(false); } if (currentTerrain.HasTag("TKKN_Wet")) { return(false); } return(true); }
public static void Postfix(Map map, IntVec3 __result) { //trying to remove swim cells and lava cells from this, hopefully it'll stop a lot of stuff. TerrainDef terrain = __result.GetTerrain(map); if (terrain != null && (terrain.HasTag("TKKN_Swim") || terrain.HasTag("TKKN_Lava"))) { //find a new cell while (true) { IntVec3 size = map.Size; int newX = Rand.Range(0, size.x); IntVec3 size2 = map.Size; IntVec3 cell = new IntVec3(newX, 0, Rand.Range(0, size2.z)); TerrainDef cellTerrain = cell.GetTerrain(map); if (cellTerrain != null && !cellTerrain.HasTag("TKKN_Swim") && !cellTerrain.HasTag("TKKN_Lava")) { __result = cell; break; } } } }
private bool CanHaveHive(int ind) { Building building = this.map.edificeGrid[ind]; if (building != null && !MapComponent_HiveGrid.CanCoexistWithHive(building.def)) { return(false); } TerrainDef terrainDef = this.map.terrainGrid.TerrainAt(ind); if (terrainDef.HasTag("Water")) { return(false); } return(terrainDef.passability != Traversability.Impassable && this.map.roofGrid.RoofAt(ind) != null);// terrainDef == null || terrainDef.holdSnow; }
public static bool Prefix(Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, float extraRotation) { Pawn pawn = thing as Pawn; if (pawn is Pawn && pawn != null) { if (pawn.RaceProps.Humanlike && pawn.Position.IsValid) { TerrainDef terrain = pawn.Position.GetTerrain(pawn.MapHeld); if (terrain != null && terrain.HasTag("TKKN_Swim")) { return(false); } } } return(true); }
public override void Place(Map map, IntVec3 position, TerrainDef rockDef) { base.Place(map, position, rockDef); if (this.place is TerrainDef) { if (this.proximitySpacing != 0) { Log.ErrorOnce("Proximity spacing used for road terrain placement; not yet supported", 60936625); } TerrainDef terrainDef = map.terrainGrid.TerrainAt(position); if (terrainDef.HasTag("Road") && !terrainDef.Removable) { map.terrainGrid.SetTerrain(position, TerrainDefOf.Gravel); } TerrainDef terrainDef2 = this.place as TerrainDef; if (terrainDef2 == TerrainDefOf.FlagstoneSandstone) { terrainDef2 = rockDef; } map.terrainGrid.SetTerrain(position, terrainDef2); if (position.OnEdge(map)) { map.roadInfo.roadEdgeTiles.Add(position); } } else if (this.place is ThingDef) { if (this.proximitySpacing > 0 && GenClosest.ClosestThing_Global(position, map.listerThings.ThingsOfDef(this.place as ThingDef), (float)this.proximitySpacing, null, null) != null) { return; } while (position.GetThingList(map).Count > 0) { position.GetThingList(map)[0].Destroy(DestroyMode.Vanish); } RoadDefGenStep_DryWithFallback.PlaceWorker(map, position, TerrainDefOf.Gravel); GenSpawn.Spawn(ThingMaker.MakeThing(this.place as ThingDef, null), position, map); } else { Log.ErrorOnce(string.Format("Can't figure out how to place object {0} while building road", this.place), 10785584); } }
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 static void Postfix(Thing __instance) { IntVec3 c = __instance.Position; Map map = __instance.Map; TerrainDef terrain = c.GetTerrain(map); if (terrain != null && terrain.HasTag("Lava")) { FireUtility.TryStartFireIn(c, map, 5f); float statValue = __instance.GetStatValue(StatDefOf.Flammability, true); bool alt = __instance.def.altitudeLayer == AltitudeLayer.Item; if (statValue == 0f && alt == true) { if (!__instance.Destroyed && __instance.def.destroyable) { __instance.Destroy(DestroyMode.Vanish); } } } }
public static void MakeWet(Pawn pawn) { HediffDef hediffDef = HediffDefOf.TKKN_Wetness; if (pawn.health.hediffSet.GetFirstHediffOfDef(hediffDef) == null && pawn.RaceProps.Humanlike) { Map map = pawn.MapHeld; IntVec3 c = pawn.Position; if (map == null || !c.IsValid) { return; } bool isWet = false; if (map.weatherManager.curWeather.rainRate > .001f) { Room room = c.GetRoom(map, RegionType.Set_All); bool roofed = map.roofGrid.Roofed(c); bool flag2 = room != null && room.UsesOutdoorTemperature; if (!roofed) { isWet = true; } } else { TerrainDef currentTerrain = c.GetTerrain(map); if (currentTerrain.HasTag("TKKN_Wet")) { isWet = true; } } if (isWet) { Hediff hediff = HediffMaker.MakeHediff(hediffDef, pawn, null); hediff.Severity = 0; pawn.health.AddHediff(hediff, null, null); } } }
public override void Place(Map map, IntVec3 position, TerrainDef rockDef, IntVec3 origin, GenStep_Roads.DistanceElement[,] distance) { if (this.onlyIfOriginAllows) { if (!GenConstruct.CanBuildOnTerrain(this.place, origin, map, Rot4.North, null) && origin.GetTerrain(map) != this.place) { return; } bool flag = false; for (int i = 0; i < 4; i++) { IntVec3 c = position + GenAdj.CardinalDirections[i]; if (c.InBounds(map) && this.chancePerPositionCurve.Evaluate(distance[c.x, c.z].fromRoad) > 0f && (GenConstruct.CanBuildOnTerrain(this.place, c, map, Rot4.North, null) || c.GetTerrain(map) == this.place) && (GenConstruct.CanBuildOnTerrain(this.place, distance[c.x, c.z].origin, map, Rot4.North, null) || distance[c.x, c.z].origin.GetTerrain(map) == this.place)) { flag = true; break; } } if (!flag) { return; } } if (!this.suppressOnTerrainTag.NullOrEmpty()) { TerrainDef terrainDef = map.terrainGrid.TerrainAt(position); if (terrainDef.HasTag(this.suppressOnTerrainTag)) { return; } } base.Place(map, position, rockDef, origin, distance); if (this.place is TerrainDef) { if (this.proximitySpacing != 0) { Log.ErrorOnce("Proximity spacing used for road terrain placement; not yet supported", 60936625, false); } TerrainDef terrainDef2 = map.terrainGrid.TerrainAt(position); TerrainDef terrainDef3 = (TerrainDef)this.place; if (terrainDef3 == TerrainDefOf.FlagstoneSandstone) { terrainDef3 = rockDef; } if (terrainDef3 == TerrainDefOf.Bridge) { if (terrainDef2 == TerrainDefOf.WaterDeep) { map.terrainGrid.SetTerrain(position, TerrainDefOf.WaterShallow); } if (terrainDef2 == TerrainDefOf.WaterOceanDeep) { map.terrainGrid.SetTerrain(position, TerrainDefOf.WaterOceanShallow); } } if (GenConstruct.CanBuildOnTerrain(terrainDef3, position, map, Rot4.North, null) && (!GenConstruct.CanBuildOnTerrain(TerrainDefOf.Bridge, position, map, Rot4.North, null) || terrainDef3 == TerrainDefOf.Bridge) && terrainDef2 != TerrainDefOf.Bridge) { if (terrainDef2.HasTag("Road") && !terrainDef2.Removable) { map.terrainGrid.SetTerrain(position, TerrainDefOf.Gravel); } map.terrainGrid.SetTerrain(position, terrainDef3); } if (position.OnEdge(map) && !map.roadInfo.roadEdgeTiles.Contains(position)) { map.roadInfo.roadEdgeTiles.Add(position); } } else if (this.place is ThingDef) { if (!GenConstruct.CanBuildOnTerrain(this.place, position, map, Rot4.North, null)) { return; } if (this.proximitySpacing > 0 && GenClosest.ClosestThing_Global(position, map.listerThings.ThingsOfDef((ThingDef)this.place), (float)this.proximitySpacing, null, null) != null) { return; } while (position.GetThingList(map).Count > 0) { position.GetThingList(map)[0].Destroy(DestroyMode.Vanish); } RoadDefGenStep_DryWithFallback.PlaceWorker(map, position, TerrainDefOf.Gravel); GenSpawn.Spawn(ThingMaker.MakeThing((ThingDef)this.place, null), position, map, WipeMode.Vanish); } else { Log.ErrorOnce(string.Format("Can't figure out how to place object {0} while building road", this.place), 10785584, false); } }
/// <summary> /// Generate a grid, add the preexisting vanilla road if needed. Add main roads. Fill the potential point list, add buildings on grid and fill the origin/layout dictionnary /// </summary> /// <param name="seed">Seed for Random</param> /// <param name="sld">SettlementLayoutDef to get all StructureLayoutDef authorized</param> /// <param name="map">The map</param> /// <returns></returns> public static CustomVector[][] GenerateGrid(int seed, SettlementLayoutDef sld, Map map) { CGO.currentGenStepMoreInfo = "Generating grid and main road"; int mapWidth = Math.Min(map.Size.x, sld.settlementSize.x), mapHeight = Math.Min(map.Size.z, sld.settlementSize.z); // Search for the smallest sized allowed structure. It will be the radius between potential building spawn points CGO.radius = 9999; for (int i = 0; i < sld.allowedStructures.Count; i++) { foreach (StructureLayoutDef item in DefDatabase <StructureLayoutDef> .AllDefsListForReading.FindAll(s => s.tags.Contains(sld.allowedStructuresConverted[i].structureLayoutTag))) { RectUtils.HeightWidthFromLayout(item, out int height, out int width); if (height < CGO.radius) { CGO.radius = height; } if (width < CGO.radius) { CGO.radius = width; } } } CGO.radius += 2; // Add to radius to ensure no building touch one another // Initialize the grid used for generation Random r = new Random(seed); CustomVector[][] grid = new CustomVector[mapWidth][]; for (int i = 0; i < mapWidth; i++) { grid[i] = new CustomVector[mapHeight]; for (int j = 0; j < mapHeight; j++) { grid[i][j] = new CustomVector(i, j); } } // Exclude non bridgeable cells for (int i = 0; i < mapWidth; i++) { for (int j = 0; j < mapHeight; j++) { TerrainDef t = map.terrainGrid.TerrainAt(new IntVec3(CGO.offset.x + i, 0, CGO.offset.y + j)); if (t.HasTag("Water") && (t.affordances == null || !t.affordances.Contains(TerrainAffordanceDefOf.Bridgeable))) { grid[i][j].Type = CellType.WATER; } } } // Main roads CGO.usePathCostReduction = false; // No path cost reduction for main road, for them to be distinct DrawXMainRoad(grid, mapWidth, mapHeight, 15, r); DrawYMainRoad(grid, mapWidth, mapHeight, 15, r); // If bigger sized settlement, add more main roads for (int i = 0; i < mapWidth / 100; i++) { if (i == 0) { DrawXMainRoad(grid, mapWidth, mapHeight, mapWidth / 2, r); DrawYMainRoad(grid, mapWidth, mapHeight, mapHeight / 2, r); } else { DrawXMainRoad(grid, mapWidth, mapHeight, 50, r); DrawYMainRoad(grid, mapWidth, mapHeight, 50, r); } } // Get vanilla world road type and use it if present if (CGO.preRoadTypes?.Count > 0) { for (int i = 0; i < mapWidth; i++) { for (int j = 0; j < mapHeight; j++) { TerrainDef t = map.terrainGrid.TerrainAt(new IntVec3(CGO.offset.x + i, 0, CGO.offset.y + j)); if (CGO.preRoadTypes.Contains(t)) { grid[i][j].Type = CellType.MAINROAD; // Add vanilla generated road to the grid } } } } CGO.usePathCostReduction = true; // Renable path cost reduction CGO.vectors = PoissonDiskSampling.Run(50, mapWidth, mapHeight, r, grid); // Get all possible points with radius CGO.doors = BuildingPlacement.Run(sld, grid, 50); // Place buildings on grid and add them/their origin into vectStruct return(grid); }
public bool AllowRenderingFor(TerrainDef terrain) { return(DebugViewSettings.drawTerrainWater || !terrain.HasTag("Water")); }
public void doMapSpawns() { if (map.Biome.defName.Contains("MA_")) { foreach (MechanoidAssimilationSpawnsDef element in DefDatabase <MechanoidAssimilationSpawnsDef> .AllDefs.Where(element => element.allowedBiome == map.Biome.defName)) { IEnumerable <IntVec3> tmpTerrain = map.AllCells.InRandomOrder(); int extraGeneration = 0; foreach (string biome in element.biomesWithExtraGeneration) { if (map.Biome.defName == biome) { extraGeneration = element.extraGeneration; } } bool canSpawn = true; if (spawnCounter == 0) { spawnCounter = Rand.RangeInclusive(element.numberToSpawn.min, element.numberToSpawn.max) + extraGeneration; //Log.Message(spawnCounter.ToString()); } foreach (IntVec3 c in tmpTerrain) { TerrainDef terrain = c.GetTerrain(map); bool flagAllowed = true; foreach (string allowed in element.terrainValidationAllowed) { if (terrain.defName == allowed) { break; } else { flagAllowed = false; } } bool flagDisallowed = true; foreach (string notAllowed in element.terrainValidationDisallowed) { if (terrain.HasTag(notAllowed)) { flagDisallowed = false; break; } } bool flagWater = true; if (!element.allowOnWater && terrain.IsWater) { flagWater = false; } bool flagCenter = true; if (element.findCellsOutsideColony) { if (!OutOfCenter(c, map, 60)) { flagCenter = false; } } canSpawn = flagAllowed & flagDisallowed & flagWater & flagCenter; if (canSpawn) { // Log.Message("Sucesful c was " + c.ToString()); Thing thing = (Thing)ThingMaker.MakeThing(element.thingDef, null); CellRect occupiedRect = GenAdj.OccupiedRect(c, thing.Rotation, thing.def.Size); if (occupiedRect.InBounds(map)) { // Log.Message("Prior to " + element.defName + " .Spawncounter was " + spawnCounter); GenSpawn.Spawn(thing, c, map); spawnCounter--; // Log.Message("Spawning " + element.defName + " .Spawncounter was " + spawnCounter); } } if (canSpawn && spawnCounter <= 0) { //Log.Message("Spawn counter is " + spawnCounter + " So I'm getting out"); spawnCounter = 0; break; } } } } this.verifyFirstTime = false; }