Index: binaries/data/mods/public/maps/random/biome_demo.js =================================================================== --- /dev/null +++ binaries/data/mods/public/maps/random/biome_demo.js @@ -0,0 +1,107 @@ +Engine.LoadLibrary("rmgen"); +Engine.LoadLibrary("rmgen-common"); +Engine.LoadLibrary("rmbiome"); + +setSelectedBiome(); + +const heightLand = 3; + +var g_Map = new RandomMap(heightLand, g_Terrains.mainTerrain); + + +const MAP_CENTER = new Vector2D(fractionToTiles(0.5), fractionToTiles(0.5)); + +const PATCH_SIZE = 30; + +const PATCH_PER_ROW = scaleByMapSize(1, 6); // * 2 + 1 in practice + +const Y_START = -2; + +Engine.SetProgress(10); +g_Map.log("Creating terrain patches"); + +{ + let x = -PATCH_PER_ROW; + let y = Y_START; + for (const terrain in g_Terrains) + { + ++x; + if (x >= PATCH_PER_ROW) + { + ++y; + x = -PATCH_PER_ROW; + } + + const placer = new RectPlacer( + new Vector2D(x * PATCH_SIZE, y * PATCH_SIZE).add(MAP_CENTER), + new Vector2D(x * PATCH_SIZE + PATCH_SIZE - 1, y * PATCH_SIZE + PATCH_SIZE - 1).add(MAP_CENTER) + ); + + createArea(placer, new TerrainPainter(g_Terrains[terrain]), []); + } + + // Create a water area. + + y = Y_START - 1; + const placer = new RectPlacer( + new Vector2D(0, 0), + new Vector2D(fractionToTiles(1), MAP_CENTER.y + Y_START * PATCH_SIZE - 1) + ); + + createArea(placer, new SmoothElevationPainter(ELEVATION_SET, -8, 12)); + + paintTerrainBasedOnHeight(-12, -1, 1, g_Terrains.water); + paintTerrainBasedOnHeight(-1, 1, 1, g_Terrains.shore); + paintTerrainBasedOnHeight(1, 3, 1, g_Terrains.shoreBlend); + +} + +Engine.SetProgress(40); +g_Map.log("Creating objects."); + +{ + let x = -PATCH_PER_ROW; + let y = Y_START; + for (const gaia in g_Gaia) + { + ++x; + if (x >= PATCH_PER_ROW) + { + ++y; + x = -PATCH_PER_ROW; + } + + for (let xx = -1; xx <= 1; ++xx) + for (let yy = -1; yy <= 1; ++yy) + g_Map.placeEntityAnywhere(g_Gaia[gaia], + 0, + new Vector2D( + x * PATCH_SIZE + PATCH_SIZE / 2 + xx * 4, + y * PATCH_SIZE + PATCH_SIZE / 2 + yy * 4 + ).add(MAP_CENTER), + 0 + ); + } + for (const gaia in g_Decoratives) + { + ++x; + if (x >= PATCH_PER_ROW) + { + ++y; + x = -PATCH_PER_ROW; + } + + for (let xx = -1; xx <= 1; ++xx) + for (let yy = -1; yy <= 1; ++yy) + g_Map.placeEntityAnywhere(g_Decoratives[gaia], + 0, + new Vector2D( + x * PATCH_SIZE + PATCH_SIZE / 2 + xx * 4, + y * PATCH_SIZE + PATCH_SIZE / 2 + yy * 4 + ).add(MAP_CENTER), + 0 + ); + } +} + +g_Map.ExportMap(); Index: binaries/data/mods/public/maps/random/biome_demo.json =================================================================== --- /dev/null +++ binaries/data/mods/public/maps/random/biome_demo.json @@ -0,0 +1,10 @@ +{ + "settings" : { + "Name" : "Biome demo", + "Script" : "biome_demo.js", + "Description" : "A random map script that shows everything a biome specifies, for quick testing.", + "CircularMap" : true, + "SupportedBiomes": "generic/", + "Keywords": ["demo"] + } +}