private void RockTypesFromUnder() { // Try to add all the rock types found in the map if (!checkedRocksUnder && rockTypesUnder.NullOrEmpty()) { foreach (IntVec3 c in this.OccupiedRect()) { // What type of terrain are we over? TerrainDef td = c.GetTerrain(Map); // If this is a valid rock type, add it to the list if (QuarryUtility.IsValidQuarryRock(td, out QuarryRockType rockType, out string key) && !rocksUnder.Contains(rockType) && !rockTypesUnder.Contains(key)) { // Log.Message($"{td} rock type {rockType.rockDef} blocks: {rockType.blockDef} with key {key}"); rocksUnder.Add(rockType); rockTypesUnder.Add(key); } } checkedRocksUnder = true; } else { for (int i = 0; i < rockTypesUnder.Count; i++) { if (QuarrySettings.quarryableStone.TryGetValue(rockTypesUnder[i], out QuarryRockType rockType)) { rocksUnder.Add(rockType); } } } }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); facilityComp = GetComp <CompAffectedByFacilities>(); if (firstSpawn) { // Set the initial quarry health quarryPercent = 1f; CellRect rect = this.OccupiedRect(); // Remove this area from the quarry grid. Quarries can never be built here again map.GetComponent <QuarryGrid>().RemoveFromGrid(rect); foreach (IntVec3 c in rect) { // What type of terrain are we over? string rockType = c.GetTerrain(Map).label.Split(' ').Last().CapitalizeFirst(); // If this is a valid rock type, add it to the list if (QuarryUtility.IsValidQuarryRock(rockType)) { rockTypesUnder.Add(rockType); } // Change the terrain here to be quarried stone if (rect.ContractedBy(WallThickness).Contains(c)) { Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGround); } else { Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGroundWall); } } // Now that all the cells have been processed, create ThingDef lists MakeThingDefListsFrom(RockTypesUnder); // Spawn filth for the quarry foreach (IntVec3 c in rect) { SpawnFilth(c); } // Change the ground back to normal quarried stone where the ladders are // This is to negate the speed decrease and encourages pawns to use the ladders foreach (IntVec3 offset in LadderOffsets) { Map.terrainGrid.SetTerrain(Position + offset.RotatedBy(Rotation), QuarryDefOf.QRY_QuarriedGround); } } }
private List <string> RockTypesFromMap() { // Try to add all the rock types found in the map List <string> list = new List <string>(); List <string> tempRockTypesUnder = Find.World.NaturalRockTypesIn(Map.Tile).Select(r => r.LabelCap).ToList(); foreach (string str in tempRockTypesUnder) { if (QuarryUtility.IsValidQuarryRock(str)) { list.Add(str); } } // This will cause an error if there still isn't a list, so make a new one using known rocks if (list.Count <= 0) { Log.Warning("Quarry:: No valid rock types were found in the map. Building list using vanilla rocks."); list = new List <string>() { "Sandstone", "Limestone", "Granite", "Marble", "Slate" }; } return(list); }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); facilityComp = GetComp <CompAffectedByFacilities>(); if (firstSpawn) { // Set the initial quarry health quarryPercent = 1f; CellRect rect = this.OccupiedRect(); // Remove this area from the quarry grid. Quarries can never be built here again // map.GetComponent<QuarryGrid>().RemoveFromGrid(rect); foreach (IntVec3 c in rect) { // What type of terrain are we over? TerrainDef td = c.GetTerrain(Map); // Original method, problem here is that mods that use prefixes like Alpha Biomes "AB_" trigger the split and only pass the prefix, not the defname // string rockType = td.defName.Split('_').First(); // this seems like a better method, mods with prfixes are a little easier to handle stone from string rockType = td.defName; if (rockType.EndsWith("_Rough")) { rockType = rockType.Replace("_Rough", ""); } else if (rockType.EndsWith("_RoughHewn")) { rockType = rockType.Replace("_RoughHewn", ""); } else if (rockType.EndsWith("_Smooth")) { rockType = rockType.Replace("_Smooth", ""); } else { continue; } // crappy alpha biomes compatability, gotta be a better method if (rockType.StartsWith("GU_")) { rockType = rockType.Replace("GU_", ""); } if (rockType.StartsWith("AB_")) { rockType = rockType.Replace("AB_", ""); } // If this is a valid rock type, add it to the list if (QuarryUtility.IsValidQuarryRock(rockType)) { rockTypesUnder.Add(rockType); } // Change the terrain here to be quarried stone if (rect.ContractedBy(WallThickness).Contains(c)) { Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGround); } else { Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGroundWall); } } // Now that all the cells have been processed, create ThingDef lists MakeThingDefListsFrom(RockTypesUnder); // Spawn filth for the quarry foreach (IntVec3 c in rect) { SpawnFilth(c); } // Change the ground back to normal quarried stone where the ladders are // This is to negate the speed decrease and encourages pawns to use the ladders foreach (IntVec3 offset in LadderOffsets) { Map.terrainGrid.SetTerrain(Position + offset.RotatedBy(Rotation), QuarryDefOf.QRY_QuarriedGround); } } }