[WorkbenchPluginAttribute(name: "Validate Rereintroduced scenario", wbModules: {"WorldEditor"})] class ERR_ValidateWorldPlugin : WorldEditorPlugin { protected bool m_Obstructed; protected bool CheckClearance(IEntity entity) { if (entity && entity.GetVObject()) m_Obstructed = true; return !m_Obstructed; } override void Run() { Validate(); } override void RunCommandline() { Validate(); } protected void Validate() { WorldEditor editor = Workbench.GetModule(WorldEditor); if (!editor) { Print("ERR VALIDATION: World Editor missing", LogLevel.ERROR); return; } WorldEditorAPI api = editor.GetApi(); if (!api) { Print("ERR VALIDATION: world API missing", LogLevel.ERROR); return; } PrintFormat("ERR VALIDATION: prison terrain=%1, radio terrain=%2, extraction terrain=%3", api.GetTerrainSurfaceY(6090,7160), api.GetTerrainSurfaceY(6500,7200), api.GetTerrainSurfaceY(7000,7500)); for (int dx = -6; dx <= 6; dx += 3) for (int dz = -6; dz <= 6; dz += 3) PrintFormat("ERR TERRAIN: x=%1 z=%2 y=%3", 6090 + dx, 7160 + dz, api.GetTerrainSurfaceY(6090 + dx, 7160 + dz)); float bestSlope = 1000; vector bestPosition; for (int x = 5800; x <= 6200; x += 10) { for (int z = 6800; z <= 7200; z += 10) { float low = 10000; float high = -10000; for (int sx = -9; sx <= 9; sx += 3) for (int sz = -15; sz <= 9; sz += 3) { float height = api.GetTerrainSurfaceY(x + sx, z + sz); low = Math.Min(low, height); high = Math.Max(high, height); } if (low > 5 && high - low < bestSlope) { m_Obstructed = false; api.GetWorld().QueryEntitiesByAABB(Vector(x - 10, low + 0.1, z - 16), Vector(x + 10, high + 5, z + 10), CheckClearance); if (m_Obstructed) continue; bestSlope = high - low; bestPosition = Vector(x, api.GetTerrainSurfaceY(x, z), z); } } } PrintFormat("ERR SITE CANDIDATE: position=%1 elevationRange=%2", bestPosition, bestSlope); string play; if (System.GetCLIParam("errPlay", play) && play == "1") editor.SwitchToGameMode(); } }