public static bool IsValidQuarryRock(TerrainDef str, out QuarryRockType rockType, out string key) { rockType = null; key = string.Empty; if (QuarrySettings.database.NullOrEmpty() && QuarrySettings.quarryableStone.NullOrEmpty()) { Log.Error("Quarry:: Trying to validate rock types before the database has been built."); return(false); } rockType = QuarrySettings.quarryableStone.Values.FirstOrFallback(x => x.terrainDefs.Contains(str)); if (rockType != null) { key = QuarrySettings.quarryableStone.FirstOrFallback(x => x.Value.terrainDefs.Contains(str)).Key; Log.Message($"Quarry:: search for {str}: {rockType} found using key {key}"); return(rockType.terrainDefs.Contains(str)); } /* * else * { * Log.Message($"Quarry:: search for {str}: failed, using old system"); * } * // If there isn't a known chunk or blocks for this, it probably isn't a rock type and wouldn't work for spawning anyways * // This allows Cupro's Stones to work, and any other mod that uses standard naming conventions for stones * if (QuarrySettings.database.Find(t => t.defName == "Chunk" + str) != null && * QuarrySettings.database.Find(t => t.defName == "Blocks" + str) != null) { * return true; * } */ return(false); }
public override string GetInspectString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(base.GetInspectString()); stringBuilder.AppendLine(Static.InspectQuarryPercent + ": " + QuarryPercent.ToStringDecimalIfSmall() + "%"); if (PlayerCanSeeOwners) { // stringBuilder.AppendLine("ForColonistUse".Translate()); if (owners.Count == 0) { stringBuilder.AppendLine("QRY_RestrictedTo".Translate() + ": " + "Nobody".Translate().ToLower()); } else if (owners.Count == 1) { stringBuilder.AppendLine("QRY_RestrictedTo".Translate() + ": " + owners[0].Label); } else { stringBuilder.Append("QRY_RestrictedTo".Translate() + ": "); bool conjugate = false; for (int i = 0; i < OwnerInspectCount; i++) { if (conjugate) { stringBuilder.Append(", "); } conjugate = true; stringBuilder.Append(owners[i].LabelShort); } if (owners.Count > 3) { stringBuilder.Append($" (+ {owners.Count - 3})"); } stringBuilder.AppendLine(); } } if (Prefs.DevMode || PlayerCanSeeOwners) { stringBuilder.AppendLine("Rock Types available: "); List <string> report = new List <string>(); for (int i = 0; i < rocksUnder.Count; i++) { QuarryRockType rockType = rocksUnder[i]; if (!report.Contains(rockType.rockDef.LabelCap)) { report.Add(rockType.rockDef.LabelCap); stringBuilder.AppendLine(" " + rockType.rockDef.LabelCap + (rockType.chunkDef != null ? ": chunks" : "") + (rockType.blockDef != null ? ((rockType.chunkDef != null ? ", " : ": ") + "blocks") : "")); } } stringBuilder.AppendLine(); } return(stringBuilder.ToString().TrimEndNewlines()); }