static bool Prefix(GenStep_ScattererBestFit __instance, ref bool __result, Map map, ref IntVec3 result) { if (__instance.def.defName.Contains("Archonexus")) { ITerrainOverride o = Patch_GenStep_Terrain.QuestArea; result = new IntVec3(o.Center.x, o.Center.y, o.Center.z); Stack <Thing> s; for (int x = o.LowX; x <= o.HighX; ++x) { for (int z = o.LowZ; z <= o.HighZ; ++z) { var i = new IntVec3(x, 0, z); if (o.IsInside(i)) { s = new Stack <Thing>(map.thingGrid.ThingsAt(i)); while (s.Count > 0) { var t = s.Pop(); if (!t.def.destroyable) { t.DeSpawn(); } } } } } __result = true; return(false); } return(true); }
static void Postfix(Map map) { //Log.Error($"Roof Edge: {Settings.RoofEdgeDepth}"); middleAreaCenter = null; if (map.TileInfo.hilliness == Hilliness.Impassable) { int radius = (int)(((float)map.Size.x + map.Size.z) * 0.25f) + Settings.OuterRadius; int middleWallSmoothness = Settings.MiddleWallSmoothness; Random r; if (Settings.TrueRandom) { r = new Random(Guid.NewGuid().GetHashCode()); } else { r = new Random((Find.World.info.name + map.Tile).GetHashCode()); } ITerrainOverride middleArea = null; if (Settings.HasMiddleArea) { middleArea = GenerateMiddleArea(r, map); } QuestArea = null; if (Patch_MapGenerator_Generate.IsQuestMap) { Log.Message("[Impassable Map Maker] map is for a quest. An open area will be created to support it."); QuestArea = GenerateAreaForQuests(r, map); } ITerrainOverride quaryArea = null; if (Settings.IncludeQuarySpot) { quaryArea = DetermineQuary(r, map, middleArea); } #if DEBUG Log.Warning( "size " + map.Size.x + " basePatchX " + basePatchX + " basePatchZ " + basePatchZ); #endif MapGenFloatGrid fertility = MapGenerator.Fertility; MapGenFloatGrid elevation = MapGenerator.Elevation; IntVec2 roofXMinMax = new IntVec2(Settings.RoofEdgeDepth, map.Size.x - Settings.RoofEdgeDepth); IntVec2 roofZMinMax = new IntVec2(Settings.RoofEdgeDepth, map.Size.z - Settings.RoofEdgeDepth); foreach (IntVec3 current in map.AllCells) { float elev = 0; if (IsMountain(current, map, radius)) { elev = 3.40282347E+38f; map.roofGrid.SetRoof(current, RoofDefOf.RoofRockThick); } else if (Settings.ScatteredRocks && IsScatteredRock(current, r, map, radius)) { elev = 0.75f; } else { elev = 0.57f; map.roofGrid.SetRoof(current, null); } if (QuestArea?.IsInside(current) == true) { elev = 0; map.roofGrid.SetRoof(current, null); } else if (quaryArea?.IsInside(current) == true) { // Gravel elev = 0.57f; map.roofGrid.SetRoof(current, null); } else if (middleArea != null) { int i = (middleWallSmoothness == 0) ? 0 : r.Next(middleWallSmoothness); if (middleArea.IsInside(current, i)) { AddMiddleAreaCell(current); elev = 0; map.roofGrid.SetRoof(current, null); } } /*if (current.x == 0 || current.x == map.Size.x - 1 || * current.z == 0 || current.z == map.Size.z - 1) * { * map.fogGrid.Notify_FogBlockerRemoved(current); * }*/ elevation[current] = elev; if (Settings.OuterShape == ImpassableShape.Fill && roofXMinMax.x > 0) { if (current.x <= roofXMinMax.x || current.x >= roofXMinMax.z || current.z <= roofZMinMax.x || current.z >= roofZMinMax.z) { elevation[current] = 0.75f; map.roofGrid.SetRoof(current, null); } } } } }
static void Postfix(Map map) { if (map.TileInfo.hilliness == Hilliness.Impassable) { int radius = (int)(((float)map.Size.x + map.Size.z) * 0.25f); int middleWallSmoothness = Settings.MiddleWallSmoothness; Random r = new Random((Find.World.info.name + map.Tile).GetHashCode()); ITerrainOverride middleArea = null; if (Settings.HasMiddleArea) { middleArea = GenerateMiddleArea(r, map); } ITerrainOverride quaryArea = null; if (Settings.IncludeQuarySpot) { quaryArea = DetermineQuary(r, map, middleArea); } #if DEBUG Log.Warning( "size " + map.Size.x + " basePatchX " + basePatchX + " basePatchZ " + basePatchZ); #endif MapGenFloatGrid fertility = MapGenerator.Fertility; MapGenFloatGrid elevation = MapGenerator.Elevation; foreach (IntVec3 current in map.AllCells) { float elev = 0; if (IsMountain(current, map, radius)) { elev = 3.40282347E+38f; } else if (Settings.ScatteredRocks && IsScatteredRock(current, r, map, radius)) { elev = 0.75f; } else { elev = 0.57f; } if (quaryArea != null && quaryArea.IsInside(current)) { // Gravel elev = 0.57f; } else if (middleArea != null) { int i = (middleWallSmoothness == 0) ? 0 : r.Next(middleWallSmoothness); if (middleArea.IsInside(current, i)) { elev = 0; } } /*if (current.x == 0 || current.x == map.Size.x - 1 || * current.z == 0 || current.z == map.Size.z - 1) * { * map.fogGrid.Notify_FogBlockerRemoved(current); * }*/ elevation[current] = elev; } } }