using HarmonyLib; using RimWorld.Planet; using Verse; namespace BlaxZonesTests { /// /// The suite hands out about 55 carved test areas, each with clearance around it. The vanilla quick /// test picks a random tile at 250x250 (Root_Play.cs:94-96), and a hilly or mountainous tile then runs /// out of open ground halfway through the suite (seen 2026-11-29: 55 areas handed out, 574 candidates /// rejected for rock). While -blaxzonestests is on, the quick-test map is 325x325 on a flat or /// small-hills tile. The tile and every position on it still vary per run. /// [StaticConstructorOnStartup] public static class QuickTestMap { public const int MapSize = 325; private const int TileAttempts = 200; static QuickTestMap() { if (!TestRunner.Enabled) return; new Harmony("blax.zones.tests.quicktestmap").Patch( AccessTools.Method(typeof(Root_Play), nameof(Root_Play.SetupForQuickTestPlay)), postfix: new HarmonyMethod(typeof(QuickTestMap), nameof(Postfix))); // Before the world and map are made, so every pawn vanilla makes for a book or tale is known. TestRunner.HookPawnWatchers(); } public static void Postfix() { GameInitData init = Find.GameInitData; init.mapSize = MapSize; for (int i = 0; i < TileAttempts && !Open(init.startingTile); i++) init.startingTile = TileFinder.RandomStartingTile(); } private static bool Open(PlanetTile tile) { Hilliness h = Find.WorldGrid[tile].hilliness; return h == Hilliness.Flat || h == Hilliness.SmallHills; } } }